﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace 文件
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string path = "C:\\Users\\Administrator\\Desktop\\新建文件夹";
            DirectoryInfo root = new DirectoryInfo(path);
            FileInfo[] fileInfos = root.GetFiles();
            fileInfos.ToList().ForEach(fileInfo =>
            {
                WriteLine(fileInfo.DirectoryName);
                WriteLine(fileInfo.Directory);
                WriteLine(fileInfo.FullName);
                WriteLine(fileInfo.Name);
                WriteLine(fileInfo.Extension); 
                WriteLine(fileInfo.CreationTime);

                string fileName = fileInfo.Name;
                string extension = fileInfo.Extension;// 后缀是带.的
                if(extension.Equals(".txt")) // 删除
                {
                    File.Delete(fileInfo.FullName);
                }else if (extension.Equals(".xls"))// 改名
                {
                    File.Move(fileInfo.FullName, fileInfo.DirectoryName+"\\bbb.xls");
                }
            });

            ReadKey();
        }
    }
}
